<template>
  <div class="driverList">
    <van-empty
      v-if="list.length === 0"
      class="custom-image"
      image="https://img01.yzcdn.cn/vant/custom-empty-image.png"
      description="暂无备案"
    />
    <div class="list"  @click="godetail(item.register_code)" v-for="(item,index) in list" :key="index">
      <van-cell-group>
        <van-field input-align="right" label="备案类型" :value="item.arrive_type_one == '1' ? '出沈': '入沈'" readonly />
        <van-field input-align="right" label="司机姓名" :value="item.driver_name" readonly />
        <van-field input-align="right" label="司机电话" :value="item.driver_tel" readonly />
        <van-field input-align="right" label="车牌号码" :value="item.car_number" readonly />
        <van-field input-align="right" label="是否匹配上企业" :value="item.yq_register_code ? '是' : '否'" readonly />
        <van-field input-align="right" label="备案时间" :value="item.create_time" readonly />
        <van-field input-align="right" label="备案状态" :value="item.type == 0?'待审核':item.type == 1?'审核成功放行':item.type == 3?'审核成功隔离':item.type == 99?'备案已作废': ''" readonly />
      </van-cell-group>
    </div>

  </div>
</template>

<script>
import { Toast } from 'vant'
import { findCarGoInfoList, getSstUserInfo } from '../../api/gov/home/index'

export default {

  name: 'driverList',
  data () {
    return {
      list: []
    }
  },
  mounted () {
    localStorage.setItem('type', 'driverList')
    // localStorage.setItem('type', 'none')
    console.log(localStorage.getItem('type'))
    if (this.$route.query.cardNo) {
      findCarGoInfoList({ driver_cardno: this.$route.query.cardNo }).then(res => {
        console.log(res)
        this.list = res.data.data
      })
    } else {
      if (this.$route.query.code) {
        let toast = Toast.loading({
          message: '加载中...',
          forbidClick: true,
          duration: 10000
        })
        getSstUserInfo({ code: this.$route.query.code }).then(res => {
          toast.clear()
          findCarGoInfoList({ driver_cardno: res.data.data.data.card_no }).then(res => {
            console.log(res)
            this.list = res.data.data
          })
        })
      }
    }
  },
  methods: {
    godetail (registerCode) {
      this.$router.push({ name: 'detail', query: { registerCode } })
    }
  }
}
</script>
<style lang="less" scoped>
.driverList{
  .list{
    border-bottom: 20px solid #f1f3f4;
    /deep/.van-field__label{
      width: 10em;
      display: flex;
      align-items: center;
    }
  }
  .custom-image .van-empty__image {
    width: 90px;
    height: 90px;
  }
}
</style>
